package homework02.exercise1;


public class Date {

    private int year;
    private int month;
    private int day;

    public Date(int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public void JudgeBigMonth(int year, int month, int day) {
        if (month != 2) {
            if (day > 0 && day <= 31) {
                if (day != 31) {
                    day += 1;
                } else {
                    if (month == 12) {
                        year += 1;
                        month = 1;
                        day = 1;
                    } else {
                        month += 1;
                        day = 1;
                    }
                }
            } else {
                System.out.println("输入的日期有误");
            }
        }

    }

    public void JudgeSmallMonth(int year, int month, int day) {
        if (month == 4 || month == 6 || month == 9 || month == 11) {
            if (day > 0 && day <= 30) {
                if (day != 30) {
                    day += 1;
                } else {
                    month += 1;
                    day = 1;
                }
            } else {
                System.out.println("输入的日期有误");

            }
        }

    }

    public void JudgeFebuary(int year, int month, int day) {
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {//29天
            if (day > 0 && day <= 29) {
                if (day != 29) {
                    day += 1;
                } else {
                    month += 1;
                    day = 1;
                }
            } else {
                System.out.println("输入的日期有误");

            }

        } else {
            if (day > 0 && day <= 28) {
                if (day != 28) {
                    day += 1;
                } else {
                    month += 1;
                    day = 1;
                }
            } else {
                System.out.println("输入的日期有误");

            }
        }

    }

    public String toString() {
        return   year +
                "年" + month +
                "月" + day +
                "日";
    }

}